// utils.js
export function debounce(fn, delay) {
    let timer = null;
    return function () {
        const context = this;
        const args = arguments;
        clearTimeout(timer);
        timer = setTimeout(() => {
            fn.apply(context, args);
        }, delay);
    };
}

export function throttle(fn, delay) {
    let canRun = true;
    return function () {
        if (!canRun) return;
        canRun = false;
        const context = this;
        const args = arguments;
        setTimeout(() => {
            fn.apply(context, args);
            canRun = true;
        }, delay);
    };
}
